package com.plugin;

import com.util.StringUtil;
import org.mybatis.generator.api.GeneratedJavaFile;
import org.mybatis.generator.api.IntrospectedColumn;
import org.mybatis.generator.api.IntrospectedTable;
import org.mybatis.generator.api.PluginAdapter;
import org.mybatis.generator.api.dom.java.*;
import org.mybatis.generator.config.PropertyRegistry;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Properties;

public class FeignGenerator extends PluginAdapter {

    private final Properties properties;

    private String author;

    private String createTime;

    @Override
    public boolean validate(List<String> warnings) {
        return true;
    }

    public FeignGenerator() {
        this.properties = new Properties();
    }

    public FeignGenerator(Properties properties) {
        this.properties = properties;
    }


    @Override
    public void setProperties(Properties properties) {
        this.properties.putAll(properties);
        this.author = properties.getProperty("author");
        SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
        this.createTime = dateFormatter.format(new Date());
    }

    /**
     * 可以生成自定义的文件
     */
    @Override
    public List<GeneratedJavaFile> contextGenerateAdditionalJavaFiles(IntrospectedTable introspectedTable) {
        List<GeneratedJavaFile> javaFiles = new ArrayList<>();
        javaFiles.add(genFeignInterfaceJavaFile(introspectedTable));
        javaFiles.add(genFeignFallbackJavaFile(introspectedTable));

        javaFiles.add(genReqVoJavaFile("Add", introspectedTable, ""));
        javaFiles.add(genReqVoJavaFile("Delete", introspectedTable, ""));
        javaFiles.add(genReqVoJavaFile("Update", introspectedTable, ""));
        javaFiles.add(genReqVoJavaFile("Update", introspectedTable, "Status"));
        javaFiles.add(genReqVoJavaFile("Query", introspectedTable, "Detail"));
        javaFiles.add(genReqVoJavaFile("Query", introspectedTable, "List"));

        javaFiles.add(genRespVoJavaFile(introspectedTable, "Detail"));
        javaFiles.add(genRespVoJavaFile(introspectedTable, "List"));
        return javaFiles;
    }

    /**
     * 生成一个自定义文件
     */
    private GeneratedJavaFile genFeignInterfaceJavaFile(IntrospectedTable introspectedTable) {
        String targetPackage = properties.getProperty("targetPackage");
        String[] split = introspectedTable.getBaseRecordType().split("\\.");
        String modelName = split[split.length - 1];
        String typeName = targetPackage + "." + modelName + "FeignService";
        //类的完全限定名（决定生成的文件的目录接口）
        Interface c = new Interface(typeName);

        //设置注释
        c.addJavaDocLine("/**");
        String remarks = introspectedTable.getRemarks().replace("表", "");
        c.addJavaDocLine(" * 描述: " + remarks);
        c.addJavaDocLine(" * 作者: " + author);
        c.addJavaDocLine(" * 日期: " + createTime);
        c.addJavaDocLine(" */");

        c.setVisibility(JavaVisibility.PUBLIC);

        c.addAnnotation("@FeignClient(value = \"FeignClientValue\", path = \"FeignClientPath\", fallback = " + modelName + "FeignServiceHystrix.class)");
        //导入的依赖包
        String basePackage = targetPackage.replace("feign", "");

        c.addImportedType(new FullyQualifiedJavaType("java.util.List"));
        c.addImportedType(new FullyQualifiedJavaType("org.springframework.web.bind.annotation.*"));
        c.addImportedType(new FullyQualifiedJavaType("org.springframework.cloud.openfeign.FeignClient"));
        c.addImportedType(new FullyQualifiedJavaType(basePackage + "feign.vo.req.*"));
        c.addImportedType(new FullyQualifiedJavaType(basePackage + "feign.vo.resp.*"));
        c.addImportedType(new FullyQualifiedJavaType(basePackage + "feign.hystrix.*"));

        //构建一个编译单元
        GeneratedJavaFile generatedJavaFile = new GeneratedJavaFile(
                c,
                context.getJavaModelGeneratorConfiguration().getTargetProject(),
                context.getProperty(PropertyRegistry.CONTEXT_JAVA_FILE_ENCODING),
                context.getJavaFormatter());

        //1.添加方法
        Method add = new Method("save" + modelName);
        add.setName("save" + modelName);
        add.setVisibility(JavaVisibility.PUBLIC);
        add.setReturnType(FullyQualifiedJavaType.getIntInstance());
        Parameter parameter = new Parameter(new FullyQualifiedJavaType("Add" + modelName + "ReqVo"), "record");
        parameter.addAnnotation("@RequestBody");
        add.addParameter(parameter);
        add.addJavaDocLine("/**");
        add.addJavaDocLine(" * 添加" + remarks);
        add.addJavaDocLine(" *");
        add.addJavaDocLine(" * @param record 请求参数");
        add.addJavaDocLine(" * @return int");
        add.addJavaDocLine(" * @author " + author);
        add.addJavaDocLine(" * @date " + createTime);
        add.addJavaDocLine(" */");
        add.addAnnotation("@PostMapping(\"/save" + modelName + "\")");
        add.setAbstract(true);

        c.addMethod(add);

        //2.删除方法
        Method del = new Method("delete" + modelName);
        del.setName("delete" + modelName);
        del.setVisibility(JavaVisibility.PUBLIC);
        del.setReturnType(FullyQualifiedJavaType.getIntInstance());
        Parameter parameter1 = new Parameter(new FullyQualifiedJavaType("Delete" + modelName + "ReqVo"), "record");
        parameter1.addAnnotation("@RequestBody");
        del.addParameter(parameter1);
        del.addJavaDocLine("/**");
        del.addJavaDocLine(" * 删除" + remarks);
        del.addJavaDocLine(" *");
        del.addJavaDocLine(" * @param record 请求参数");
        del.addJavaDocLine(" * @return int");
        del.addJavaDocLine(" * @author " + author);
        del.addJavaDocLine(" * @date " + createTime);
        del.addJavaDocLine(" */");
        del.addAnnotation("@PostMapping(\"/delete" + modelName + "\")");
        del.setAbstract(true);

        c.addMethod(del);

        //3.更新方法
        Method update = new Method("update" + modelName);
        update.setName("update" + modelName);
        update.setVisibility(JavaVisibility.PUBLIC);
        update.setReturnType(FullyQualifiedJavaType.getIntInstance());
        Parameter parameter2 = new Parameter(new FullyQualifiedJavaType("Update" + modelName + "ReqVo"), "record");
        parameter2.addAnnotation("@RequestBody");
        update.addParameter(parameter2);
        update.addJavaDocLine("/**");
        update.addJavaDocLine(" * 更新" + remarks);
        update.addJavaDocLine(" *");
        update.addJavaDocLine(" * @param record 请求参数");
        update.addJavaDocLine(" * @return int");
        update.addJavaDocLine(" * @author " + author);
        update.addJavaDocLine(" * @date " + createTime);
        update.addJavaDocLine(" */");
        update.addAnnotation("@PostMapping(\"/update" + modelName + "\")");
        update.setAbstract(true);

        c.addMethod(update);

        //4.更新状态方法
        Method updateStatus = new Method("update" + modelName + "Status");
        updateStatus.setName("update" + modelName + "Status");
        updateStatus.setVisibility(JavaVisibility.PUBLIC);
        updateStatus.setReturnType(FullyQualifiedJavaType.getIntInstance());
        Parameter parameter3 = new Parameter(new FullyQualifiedJavaType("Update" + modelName + "StatusReqVo"), "record");
        parameter3.addAnnotation("@RequestBody");
        updateStatus.addParameter(parameter3);
        updateStatus.addJavaDocLine("/**");
        updateStatus.addJavaDocLine(" * 更新" + remarks + "状态");
        updateStatus.addJavaDocLine(" *");
        updateStatus.addJavaDocLine(" * @param record 请求参数");
        updateStatus.addJavaDocLine(" * @return int");
        updateStatus.addJavaDocLine(" * @author " + author);
        updateStatus.addJavaDocLine(" * @date " + createTime);
        updateStatus.addJavaDocLine(" */");
        updateStatus.addAnnotation("@PostMapping(\"/update" + modelName + "Status\")");
        updateStatus.setAbstract(true);

        c.addMethod(updateStatus);

        //5.查询详情
        Method query = new Method("query" + modelName + "Detail");
        query.setName("query" + modelName + "Detail");
        query.setVisibility(JavaVisibility.PUBLIC);
        query.setReturnType(new FullyQualifiedJavaType("Query" + modelName + "DetailRespVo"));
        Parameter parameter4 = new Parameter(new FullyQualifiedJavaType("Query" + modelName + "DetailReqVo"), "record");
        parameter4.addAnnotation("@RequestBody");
        query.addParameter(parameter4);
        query.addJavaDocLine("/**");
        query.addJavaDocLine(" * 查询" + remarks + "详情");
        query.addJavaDocLine(" *");
        query.addJavaDocLine(" * @param record 请求参数");
        query.addJavaDocLine(" * @return Query" + modelName + "DetailRespVo");
        query.addJavaDocLine(" * @author " + author);
        query.addJavaDocLine(" * @date " + createTime);
        query.addJavaDocLine(" */");
        query.addAnnotation("@PostMapping(\"/query" + modelName + "Detail\")");
        query.setAbstract(true);

        c.addMethod(query);

        //6.查询列表
        Method queryList = new Method("query" + modelName + "List");
        queryList.setName("query" + modelName + "List");
        queryList.setVisibility(JavaVisibility.PUBLIC);
        FullyQualifiedJavaType newArrayListInstance = FullyQualifiedJavaType.getNewListInstance();
        newArrayListInstance.addTypeArgument(new FullyQualifiedJavaType("Query" + modelName + "ListRespVo"));
        queryList.setReturnType(newArrayListInstance);
        Parameter parameter5 = new Parameter(new FullyQualifiedJavaType("Query" + modelName + "ListReqVo"), "record");
        parameter5.addAnnotation("@RequestBody");
        queryList.addParameter(parameter5);
        queryList.addJavaDocLine("/**");
        queryList.addJavaDocLine(" * 查询列表" + remarks + "列表");
        queryList.addJavaDocLine(" *");
        queryList.addJavaDocLine(" * @param record 请求参数");
        queryList.addJavaDocLine(" * @return List<Query" + modelName + "ListRespVo>");
        queryList.addJavaDocLine(" * @author " + author);
        queryList.addJavaDocLine(" * @date " + createTime);
        queryList.addJavaDocLine(" */");
        queryList.addAnnotation("@PostMapping(\"/query" + modelName + "List\")");
        queryList.setAbstract(true);

        c.addMethod(queryList);

        return generatedJavaFile;
    }

    /**
     * 生成一个自定义文件
     */
    private GeneratedJavaFile genFeignFallbackJavaFile(IntrospectedTable introspectedTable) {
        String targetPackage = properties.getProperty("targetPackage");
        String[] split = introspectedTable.getBaseRecordType().split("\\.");
        String modelName = split[split.length - 1];
        String typeName = targetPackage + ".hystrix." + modelName + "FeignServiceHystrix";
        //类的完全限定名（决定生成的文件的目录接口）
        TopLevelClass c = new TopLevelClass(typeName);

        //设置注释
        c.addJavaDocLine("/**");
        String remarks = introspectedTable.getRemarks().replace("表", "");
        c.addJavaDocLine(" * 描述: " + remarks);
        c.addJavaDocLine(" * 作者: " + author);
        c.addJavaDocLine(" * 日期: " + createTime);
        c.addJavaDocLine(" */");

        c.setVisibility(JavaVisibility.PUBLIC);

        c.addSuperInterface(new FullyQualifiedJavaType(modelName + "FeignService"));

        c.addAnnotation("@Component");
        //导入的依赖包

        c.addImportedType(new FullyQualifiedJavaType("java.util.List"));
        c.addImportedType(new FullyQualifiedJavaType("org.springframework.stereotype.Component"));
        c.addImportedType(new FullyQualifiedJavaType(targetPackage + "." + modelName + "FeignService"));
        c.addImportedType(new FullyQualifiedJavaType(targetPackage + ".vo.req.*"));
        c.addImportedType(new FullyQualifiedJavaType(targetPackage + ".vo.resp.*"));

        //构建一个编译单元
        GeneratedJavaFile generatedJavaFile = new GeneratedJavaFile(
                c,
                context.getJavaModelGeneratorConfiguration().getTargetProject(),
                context.getProperty(PropertyRegistry.CONTEXT_JAVA_FILE_ENCODING),
                context.getJavaFormatter());

        //1.添加方法
        Method add = new Method("save" + modelName);
        add.setName("save" + modelName);
        add.setVisibility(JavaVisibility.PUBLIC);
        add.setReturnType(FullyQualifiedJavaType.getIntInstance());
        add.addParameter(new Parameter(new FullyQualifiedJavaType("Add" + modelName + "ReqVo"), "record"));
        add.addJavaDocLine("/**");
        add.addJavaDocLine(" * 添加" + remarks);
        add.addJavaDocLine(" *");
        add.addJavaDocLine(" * @param record 请求参数");
        add.addJavaDocLine(" * @return int");
        add.addJavaDocLine(" * @author " + author);
        add.addJavaDocLine(" * @date " + createTime);
        add.addJavaDocLine(" */");
        add.addAnnotation("@Override");

        add.addBodyLine("return 0;");
        c.addMethod(add);

        //2.删除方法
        Method del = new Method("delete" + modelName);
        del.setName("delete" + modelName);
        del.setVisibility(JavaVisibility.PUBLIC);
        del.setReturnType(FullyQualifiedJavaType.getIntInstance());
        del.addParameter(new Parameter(new FullyQualifiedJavaType("Delete" + modelName + "ReqVo"), "record"));
        del.addJavaDocLine("/**");
        del.addJavaDocLine(" * 删除" + remarks);
        del.addJavaDocLine(" *");
        del.addJavaDocLine(" * @param record 请求参数");
        del.addJavaDocLine(" * @return int");
        del.addJavaDocLine(" * @author " + author);
        del.addJavaDocLine(" * @date " + createTime);
        del.addJavaDocLine(" */");
        del.addAnnotation("@Override");

        del.addBodyLine("return 0;");
        c.addMethod(del);

        //3.更新方法
        Method update = new Method("update" + modelName);
        update.setName("update" + modelName);
        update.setVisibility(JavaVisibility.PUBLIC);
        update.setReturnType(FullyQualifiedJavaType.getIntInstance());
        update.addParameter(new Parameter(new FullyQualifiedJavaType("Update" + modelName + "ReqVo"), "record"));
        update.addJavaDocLine("/**");
        update.addJavaDocLine(" * 更新" + remarks);
        update.addJavaDocLine(" *");
        update.addJavaDocLine(" * @param record 请求参数");
        update.addJavaDocLine(" * @return int");
        update.addJavaDocLine(" * @author " + author);
        update.addJavaDocLine(" * @date " + createTime);
        update.addJavaDocLine(" */");
        update.addAnnotation("@Override");

        update.addBodyLine("return 0;");
        c.addMethod(update);

        //4.更新状态方法
        Method updateStatus = new Method("update" + modelName + "Status");
        updateStatus.setName("update" + modelName + "Status");
        updateStatus.setVisibility(JavaVisibility.PUBLIC);
        updateStatus.setReturnType(FullyQualifiedJavaType.getIntInstance());
        updateStatus.addParameter(new Parameter(new FullyQualifiedJavaType("Update" + modelName + "StatusReqVo"), "record"));
        updateStatus.addJavaDocLine("/**");
        updateStatus.addJavaDocLine(" * 更新" + remarks + "状态");
        updateStatus.addJavaDocLine(" *");
        updateStatus.addJavaDocLine(" * @param record 请求参数");
        updateStatus.addJavaDocLine(" * @return int");
        updateStatus.addJavaDocLine(" * @author " + author);
        updateStatus.addJavaDocLine(" * @date " + createTime);
        updateStatus.addJavaDocLine(" */");
        updateStatus.addAnnotation("@Override");

        updateStatus.addBodyLine("return 0;");
        c.addMethod(updateStatus);

        //5.查询详情
        Method query = new Method("query" + modelName + "Detail");
        query.setName("query" + modelName + "Detail");
        query.setVisibility(JavaVisibility.PUBLIC);
        query.setReturnType(new FullyQualifiedJavaType("Query" + modelName + "DetailRespVo"));
        query.addParameter(new Parameter(new FullyQualifiedJavaType("Query" + modelName + "DetailReqVo"), "record"));
        query.addJavaDocLine("/**");
        query.addJavaDocLine(" * 查询" + remarks + "详情");
        query.addJavaDocLine(" *");
        query.addJavaDocLine(" * @param record 请求参数");
        query.addJavaDocLine(" * @return obj");
        query.addJavaDocLine(" * @author " + author);
        query.addJavaDocLine(" * @date " + createTime);
        query.addJavaDocLine(" */");
        query.addAnnotation("@Override");

        query.addBodyLine("return null;");
        c.addMethod(query);

        //6.查询列表
        Method queryList = new Method("query" + modelName + "List");
        queryList.setName("query" + modelName + "List");
        queryList.setVisibility(JavaVisibility.PUBLIC);
        FullyQualifiedJavaType newArrayListInstance = FullyQualifiedJavaType.getNewListInstance();
        newArrayListInstance.addTypeArgument(new FullyQualifiedJavaType("Query" + modelName + "ListRespVo"));
        queryList.setReturnType(newArrayListInstance);
        queryList.addParameter(new Parameter(new FullyQualifiedJavaType("Query" + modelName + "ListReqVo"), "record"));
        queryList.addJavaDocLine("/**");
        queryList.addJavaDocLine(" * 查询列表" + remarks + "列表");
        queryList.addJavaDocLine(" *");
        queryList.addJavaDocLine(" * @param record 请求参数");
        queryList.addJavaDocLine(" * @return obj");
        queryList.addJavaDocLine(" * @author " + author);
        queryList.addJavaDocLine(" * @date " + createTime);
        queryList.addJavaDocLine(" */");
        queryList.addAnnotation("@Override");

        queryList.addBodyLine("return null;");
        c.addMethod(queryList);

        return generatedJavaFile;
    }

    /**
     * 生成一个自定义文件
     */
    private GeneratedJavaFile genReqVoJavaFile(String type, IntrospectedTable introspectedTable, String suffix) {
        String targetPackage = properties.getProperty("targetPackage");
        String[] split = introspectedTable.getBaseRecordType().split("\\.");
        String typeName = targetPackage + ".vo.req." + type + split[split.length - 1] + suffix + "ReqVo";
        //类的完全限定名（决定生成的文件的目录接口）
        TopLevelClass c = new TopLevelClass(typeName);

        //设置注释
        c.addJavaDocLine("/**");
        String remarks = introspectedTable.getRemarks().replace("表", "");
        c.addJavaDocLine(" * 描述: " + remarks);
        c.addJavaDocLine(" * 作者: " + author);
        c.addJavaDocLine(" * 日期: " + createTime);
        c.addJavaDocLine(" */");

        c.addJavaDocLine("@Data");
        c.addJavaDocLine("@Builder");
        c.addJavaDocLine("@NoArgsConstructor");
        c.addJavaDocLine("@AllArgsConstructor");

        c.setVisibility(JavaVisibility.PUBLIC);

        c.addSuperInterface(new FullyQualifiedJavaType("Serializable"));
        //导入的依赖包
        c.addImportedType(new FullyQualifiedJavaType("java.io.Serializable"));
        c.addImportedType(new FullyQualifiedJavaType("lombok.*"));
        c.addImportedType(new FullyQualifiedJavaType("io.swagger.v3.oas.annotations.media.*"));
        c.addImportedType(new FullyQualifiedJavaType("jakarta.validation.constraints.*"));
        //构建一个编译单元
        GeneratedJavaFile generatedJavaFile = new GeneratedJavaFile(
                c,
                context.getJavaModelGeneratorConfiguration().getTargetProject(),
                context.getProperty(PropertyRegistry.CONTEXT_JAVA_FILE_ENCODING),
                context.getJavaFormatter());

        //分页设置
        if ("List".equals(suffix)) {
            Field pageNum = new Field("pageNum", new FullyQualifiedJavaType("java.lang.Integer"));
            pageNum.setVisibility(JavaVisibility.PRIVATE);
            pageNum.setName("pageNum");
            pageNum.setType(new FullyQualifiedJavaType("java.lang.Integer"));
            pageNum.setInitializationString("1");
            pageNum.addJavaDocLine("/** pageNum第几页 **/");
            c.addField(pageNum);

            Field pageSize = new Field("pageSize", new FullyQualifiedJavaType("java.lang.Integer"));
            pageSize.setVisibility(JavaVisibility.PRIVATE);
            pageSize.setName("pageSize");
            pageSize.setType(new FullyQualifiedJavaType("java.lang.Integer"));
            pageSize.setInitializationString("10");
            pageSize.addJavaDocLine("/** pageSize每页数量 **/");
            c.addField(pageSize);
        }

        for (IntrospectedColumn column : introspectedTable.getAllColumns()) {
            Field f = new Field(column.getJavaProperty(),column.getFullyQualifiedJavaType());
            f.setVisibility(JavaVisibility.PRIVATE);
            f.setName(column.getJavaProperty());
            f.setType(column.getFullyQualifiedJavaType());
            f.addJavaDocLine("/** " + column.getRemarks() + " **/");
            if (column.getJavaProperty().contains("update") || column.getJavaProperty().contains("create")) {
                continue;
            }
            if ("java.util.Date".equals(column.getFullyQualifiedJavaType().getFullyQualifiedName())) {
                f.setType(new FullyQualifiedJavaType("java.lang.String"));
            }
            if ("java.lang.Byte".equals(column.getFullyQualifiedJavaType().getFullyQualifiedName())) {
                f.setType(new FullyQualifiedJavaType("java.lang.Integer"));
            }
            if (!"java.lang.String".equals(f.getType().getFullyQualifiedName())) {
                f.addJavaDocLine("@NotNull(message = \"" + column.getJavaProperty() + column.getRemarks() + "不能为空\")");
            } else {
                f.addJavaDocLine("@NotBlank(message = \"" + column.getJavaProperty() + column.getRemarks() + "不能为空\")");
            }
            c.addField(f);
        }


        return generatedJavaFile;
    }

    private GeneratedJavaFile genRespVoJavaFile(IntrospectedTable introspectedTable, String suffix) {
        String targetPackage = properties.getProperty("targetPackage");
        String[] split = introspectedTable.getBaseRecordType().split("\\.");
        String typeName = targetPackage + ".vo.resp.Query" + split[split.length - 1] + suffix + "RespVo";
        //类的完全限定名（决定生成的文件的目录接口）
        TopLevelClass c = new TopLevelClass(typeName);

        //设置注释
        c.addJavaDocLine("/**");
        String remarks = introspectedTable.getRemarks().replace("表", "");
        c.addJavaDocLine(" * 描述: " + remarks);
        c.addJavaDocLine(" * 作者: " + author);
        c.addJavaDocLine(" * 日期: " + createTime);
        c.addJavaDocLine(" */");

        c.addJavaDocLine("@Data");
        c.addJavaDocLine("@Builder");
        c.addJavaDocLine("@NoArgsConstructor");
        c.addJavaDocLine("@AllArgsConstructor");

        c.setVisibility(JavaVisibility.PUBLIC);

        c.addSuperInterface(new FullyQualifiedJavaType("Serializable"));
        //导入的依赖包
        c.addImportedType(new FullyQualifiedJavaType("java.io.Serializable"));
        c.addImportedType(new FullyQualifiedJavaType("java.util.Date"));
        c.addImportedType(new FullyQualifiedJavaType("lombok.*"));
        //构建一个编译单元
        GeneratedJavaFile generatedJavaFile = new GeneratedJavaFile(
                c,
                context.getJavaModelGeneratorConfiguration().getTargetProject(),
                context.getProperty(PropertyRegistry.CONTEXT_JAVA_FILE_ENCODING),
                context.getJavaFormatter());

        for (IntrospectedColumn column : introspectedTable.getAllColumns()) {
            Field f = new Field(column.getJavaProperty(),column.getFullyQualifiedJavaType());
            f.setVisibility(JavaVisibility.PRIVATE);
//            f.setName(column.getJavaProperty());
//            f.setType(column.getFullyQualifiedJavaType());
            f.addJavaDocLine("/** " + column.getRemarks() + " **/");
            if ("java.util.Date".equals(column.getFullyQualifiedJavaType().getFullyQualifiedName())) {
                f.addAnnotation("@JsonFormat(pattern = \"yyyy-MM-dd HH:mm:ss\", timezone = \"GMT+8\")");
                c.addImportedType("com.fasterxml.jackson.annotation.JsonFormat");
            }
            System.out.println("f = " + column.getFullyQualifiedJavaType().getFullyQualifiedName());
            if ("java.lang.Byte".equals(column.getFullyQualifiedJavaType().getFullyQualifiedName())) {
                f.setType(new FullyQualifiedJavaType("java.lang.Integer"));
            }
            c.addField(f);
        }

        return generatedJavaFile;
    }
}
